]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
PopupImageMenuItem: always show icon, on the right, not the left
authorDan Winship <danw@gnome.org>
Tue, 19 Oct 2010 15:59:23 +0000 (11:59 -0400)
committerDan Winship <danw@gnome.org>
Mon, 25 Oct 2010 20:54:45 +0000 (16:54 -0400)
In the new mockups, the user menu icons are on the right, not the
left.

Also, get rid of the idea of optional icons; the design doesn't have
icons on those items, and there probably aren't going to be symbolic
versions of some of those icons anyway. So if the caller specifies
PopupImageMenuItem, then always show an icon, and just use regular
PopupMenuItems for the items that don't have icons in the current
design.

https://bugzilla.gnome.org/show_bug.cgi?id=631193

js/ui/popupMenu.js
js/ui/statusMenu.js

index cb17c021a2c5ff540d6c39e758c61453683a2e3d..934d35446a1b2c99a77f38ba805b8179763d8750 100644 (file)
@@ -372,64 +372,34 @@ PopupSwitchMenuItem.prototype = {
 }
 
 
-function PopupImageMenuItem(text, iconName, alwaysShowImage) {
-    this._init(text, iconName, alwaysShowImage);
+function PopupImageMenuItem(text, iconName) {
+    this._init(text, iconName);
 }
 
-// We need to instantiate a GtkImageMenuItem so it
-// hooks up its properties on the GtkSettings
-var _gtkImageMenuItemCreated = false;
-
 PopupImageMenuItem.prototype = {
     __proto__: PopupBaseMenuItem.prototype,
 
-    _init: function (text, iconName, alwaysShowImage) {
+    _init: function (text, iconName) {
         PopupBaseMenuItem.prototype._init.call(this);
 
-        if (!_gtkImageMenuItemCreated) {
-            let menuItem = new Gtk.ImageMenuItem();
-            menuItem.destroy();
-            _gtkImageMenuItemCreated = true;
-        }
-
-        this._alwaysShowImage = alwaysShowImage;
-        this._iconName = iconName;
         this._size = 16;
 
         let box = new St.BoxLayout({ style_class: 'popup-image-menu-item' });
         this.actor.set_child(box);
-        this._imageBin = new St.Bin({ width: this._size, height: this._size });
-        box.add(this._imageBin, { y_fill: false });
         this.label = new St.Label({ text: text });
         box.add(this.label, { expand: true });
+        this._imageBin = new St.Bin({ width: this._size, height: this._size });
+        box.add(this._imageBin, { y_fill: false });
 
-        if (!alwaysShowImage) {
-            let settings = Gtk.Settings.get_default();
-            settings.connect('notify::gtk-menu-images', Lang.bind(this, this._onMenuImagesChanged));
-        }
-        this._onMenuImagesChanged();
+        this.setIcon(iconName);
     },
 
-    _onMenuImagesChanged: function() {
-        let show;
-        if (this._alwaysShowImage) {
-            show = true;
-        } else {
-            let settings = Gtk.Settings.get_default();
-            show = settings.gtk_menu_images;
-        }
-        if (!show) {
-            this._imageBin.hide();
-        } else {
-            let img = St.TextureCache.get_default().load_icon_name(this._iconName, St.IconType.SYMBOLIC, this._size);
-            this._imageBin.set_child(img);
-            this._imageBin.show();
-        }
-    },
-    
     setIcon: function(name) {
-        this._iconName = name;
-        this._onMenuImagesChanged();
+        if (this._imageBin.child)
+            this._imageBin.child.destroy();
+
+        let img = St.TextureCache.get_default().load_icon_name(name, St.IconType.SYMBOLIC, this._size);
+        this._imageBin.set_child(img);
     }
 };
 
index 9aae26cb48dea6b1d1fefef84faf27c3fc90b316..1979668e18e1e963042a6563cd749dffa3557a09 100644 (file)
@@ -109,31 +109,31 @@ StatusMenuButton.prototype = {
         item = new PopupMenu.PopupSeparatorMenuItem();
         this.menu.addMenuItem(item);
 
-        item = new PopupMenu.PopupImageMenuItem(_("Account Information..."), 'user-info');
+        item = new PopupMenu.PopupMenuItem(_("Account Information..."));
         item.connect('activate', Lang.bind(this, this._onAccountInformationActivate));
         this.menu.addMenuItem(item);
 
-        item = new PopupMenu.PopupImageMenuItem(_("System Settings..."), 'preferences-desktop');
+        item = new PopupMenu.PopupMenuItem(_("System Settings..."));
         item.connect('activate', Lang.bind(this, this._onPreferencesActivate));
         this.menu.addMenuItem(item);
 
         item = new PopupMenu.PopupSeparatorMenuItem();
         this.menu.addMenuItem(item);
 
-        item = new PopupMenu.PopupImageMenuItem(_("Lock Screen"), 'system-lock-screen');
+        item = new PopupMenu.PopupMenuItem(_("Lock Screen"));
         item.connect('activate', Lang.bind(this, this._onLockScreenActivate));
         this.menu.addMenuItem(item);
 
-        item = new PopupMenu.PopupImageMenuItem(_("Switch User"), 'system-users');
+        item = new PopupMenu.PopupMenuItem(_("Switch User"));
         item.connect('activate', Lang.bind(this, this._onLoginScreenActivate));
         this.menu.addMenuItem(item);
         this._loginScreenItem = item;
 
-        item = new PopupMenu.PopupImageMenuItem(_("Log Out..."), 'system-log-out');
+        item = new PopupMenu.PopupMenuItem(_("Log Out..."));
         item.connect('activate', Lang.bind(this, this._onQuitSessionActivate));
         this.menu.addMenuItem(item);
 
-        item = new PopupMenu.PopupImageMenuItem(_("Shut Down..."), 'system-shutdown');
+        item = new PopupMenu.PopupMenuItem(_("Shut Down..."));
         item.connect('activate', Lang.bind(this, this._onShutDownActivate));
         this.menu.addMenuItem(item);
     },